USE [CTEM-DB-v1]
GO

/****** Object:  StoredProcedure [dbo].[Employee_CreateSalary]    Script Date: 02/10/2012 11:28:02 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		TienDH
-- Create date: 12/05/2011
-- Description:	Get full employee's information
-- =============================================
CREATE PROCEDURE [dbo].[Employee_CreateSalary]	
	@EmployeeID		BIGINT,
	@Month			VARCHAR(6),
	@Salary			BIGINT,
	@SalaryPC		BIGINT,
	@TotalAllowance	BIGINT,	
	@DebtPay		BIGINT,
	@Debt1			BIGINT,
	@Debt2			BIGINT,
	@TotalAdvanceSalary BIGINT,
	@ActualIncome	BIGINT,
	@GenDebt		BIGINT,
	@DateReceive	DATETIME,
	@isPay			BIT
AS
BEGIN
	DECLARE @date	DATETIME
	SET		@date = GETDATE()
	INSERT INTO EmployeeSalary
			(EmployeeID, Month, Salary, SalaryPC, TotalAllowance, DebtPay, Debt1, Debt2, TotalAdvanceSalary, ActualIncome, GenerateDebt, DateReceive, isPay, CreatedDate, LastUpdate)
	VALUES	(@EmployeeID, @Month, @Salary, @SalaryPC, @TotalAllowance, @DebtPay, @Debt1, @Debt2, @TotalAdvanceSalary, @ActualIncome, @GenDebt, @DateReceive, @isPay, @date, @date)
	
	UPDATE	Employee
	SET		TotalDebt = TotalDebt - @DebtPay + @GenDebt
	WHERE	EmployeeID = @EmployeeID	
END

GO

